// app.js
import './utils/utils'
import './utils/http'
App({
  onLaunch(){
    this.getToken()
  },
  globalData: {},
  token:'',
  getToken(){
    wx.getStorage({
      key:'token',
      success:(res)=>{
        this.token = res.data
      },
      fail:()=>{}
    })
  },
  setToken(token,refresh_token){
    //拼凑合法token格式
    token = 'Bearer' + token
    refresh_token = 'Bearer' + refresh_token
    //本地存储token和refresh_token
    wx.setStorageSync('token', token)
    wx.setStorageSync('refresh_toekn', refresh_token)
    //更新全局token和refresh_token
    this.token=token
    this.refresh_token=refresh_token
  }
})
